<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'order.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/style.css">
<script type="text/javascript"
	src="<%=basePath%>My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=basePath%>js/jquery-1.8.3.js"></script>
<script language=javascript>
	function selectAll() {
		var a = document.getElementsByName("weektype");
		var check = document.getElementById("checkall");
		if (check.checked) {
			for ( var i = 0; i < a.length; i++) {
				a[i].checked = true;
			}
		} else {
			for ( var i = 0; i < a.length; i++) {
				a[i].checked = false;
			}
		}
	}
	function selectodd() {
		var a = document.getElementsByName("weektype");
		var checkodd = document.getElementById("checkodd");
		if (checkodd.checked) {
			for ( var i = 0; i < a.length; i++) {
				if (i % 2 == 0) {
					a[i].checked = true;
				}
			}
		} else {
			for ( var i = 0; i < a.length; i++) {
				a[i].checked = false;
			}
		}
	}
	function selecteven() {
		var a = document.getElementsByName("weektype");
		var checkeven = document.getElementById("checkeven");
		if (checkeven.checked) {
			for ( var i = 0; i < a.length; i++) {
				if (i % 2 > 0) {
					a[i].checked = true;
				}
			}
		} else {
			for ( var i = 0; i < a.length; i++) {
				a[i].checked = false;
			}
		}
	}
</script>
</head>
<body>
	<ul id="tabsmenu" class="tabsmenu">
		<li class="active"><a>批量预约</a>
		</li>
	</ul>
	<div id="tab1" class="tabcontent">
		<div class="form">
			<form action="pickOrder.action" method="POST">
				<div class="form_row">
					<label id="checklabel" flag="false">预约时间:</label>
					<div id="checkbox" style="width: 650px;"></div>
					全选<input id="checkall" type="checkbox" onclick="selectAll()" /> 奇数<input
						id="checkodd" type="checkbox" onclick="selectodd()" /> 偶数<input
						id="checkeven" type="checkbox" onclick="selecteven()" /> <select
						name="dayofweek">
						<option value="2">星期一</option>
						<option value="3">星期二</option>
						<option value="4">星期三</option>
						<option value="5">星期四</option>
						<option value="6">星期五</option>
					</select>
				</div>
				<div class="form_row">
					<label>课程名:</label> <input type="text" class="form_input"
						name="course" />
				</div>
				<c:if test="${teacher.username!='admin' }">
					<input type="hidden" value="${teacher.name }" name="name">
				</c:if>
				<c:if test="${teacher.username=='admin' }">
					<div class="form_row">
						<label>教师名:</label> <input type="text" class="form_input"
							name="name" value="" />
					</div>
				</c:if>
				<div class="form_row">
					<label>班级:</label> <input type="text" class="form_input"
						name="clsname" />
				</div>
				<div class="form_row">
					<label>人数:</label> <input type="text" class="form_input"
						name="number" />
				</div>
				<div class="form_row">
					<label>实验室：</label> <select id="labelRoom" class="form_input"
						status="false" name="labid">
						<option value="0">---------请选择---------</option>
					</select>
				</div>
				<div class="form_row">
					<label>节次：</label> <select class="form_input" name="type">
						<option value="1">第一大节</option>
						<option value="2">第二大节</option>
						<option value="3">第三大节</option>
						<option value="4">第四大节</option>
					</select>
				</div>
				<div class="form_row">
					<input type="submit" class="form_submit" value="Submit" />
				</div>
				<div class="clear"></div>
			</form>
		</div>
	</div>
</body>
<script type="text/javascript">
	$(document)
			.ready(
					function() {
						var status = $("#labelRoom").attr("status");
						if ("false" == status) {
							$.ajax({
								type : "post",
								url : "ajaxlab.action",
								dataType : "json",
								success : function(data) {
									var content = "";
									$.each(data, function(i, item) {
										var LId = item["LId"];
										var labName = item["labName"];
										content += "<option value='"+LId+"'>"
												+ labName + "</option>";
									});
									$("#labelRoom").append(content);
									$("#labelRoom").attr("status", "true");
								},
								error : function(XMLHttpRequest, textStatus,
										errorThrown) {
									console.info(errorThrown);
								}
							});
						}
						var flag = $("#checklabel").attr("flag");
						if ("false" == flag) {
							$
									.ajax({
										type : "post",
										url : "ajaxgetmyweek.action",
										dataType : "json",
										success : function(data) {
											var content = "";
											$
													.each(
															data,
															function(i, item) {
																var value = item["value"];
																var name = item["name"];
																content += "<input type='checkbox' name='weektype' value='"+value+"'>第"
																		+ name
																		+ "周";
															});
											$("#checkbox").append(content);
											$("#checklabel").attr("flag",
													"true");
										},
										error : function(XMLHttpRequest,
												textStatus, errorThrown) {
											console.info(errorThrown);
										}
									});
						}
					});
</script>
</html>

